/**
 */
package mvc_generator.mVCGenerator.impl;

import java.util.Collection;

import mvc_generator.mVCGenerator.Bloc;
import mvc_generator.mVCGenerator.FormValidation;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Form Validation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.FormValidationImpl#getValidatedFormName <em>Validated Form Name</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.FormValidationImpl#getBlocs <em>Blocs</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FormValidationImpl extends MinimalEObjectImpl.Container implements FormValidation
{
  /**
   * The default value of the '{@link #getValidatedFormName() <em>Validated Form Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatedFormName()
   * @generated
   * @ordered
   */
  protected static final String VALIDATED_FORM_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getValidatedFormName() <em>Validated Form Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatedFormName()
   * @generated
   * @ordered
   */
  protected String validatedFormName = VALIDATED_FORM_NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getBlocs() <em>Blocs</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBlocs()
   * @generated
   * @ordered
   */
  protected EList<Bloc> blocs;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FormValidationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.FORM_VALIDATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getValidatedFormName()
  {
    return validatedFormName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValidatedFormName(String newValidatedFormName)
  {
    String oldValidatedFormName = validatedFormName;
    validatedFormName = newValidatedFormName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME, oldValidatedFormName, validatedFormName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Bloc> getBlocs()
  {
    if (blocs == null)
    {
      blocs = new EObjectContainmentEList<Bloc>(Bloc.class, this, MVCGeneratorPackage.FORM_VALIDATION__BLOCS);
    }
    return blocs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__BLOCS:
        return ((InternalEList<?>)getBlocs()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        return getValidatedFormName();
      case MVCGeneratorPackage.FORM_VALIDATION__BLOCS:
        return getBlocs();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        setValidatedFormName((String)newValue);
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__BLOCS:
        getBlocs().clear();
        getBlocs().addAll((Collection<? extends Bloc>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        setValidatedFormName(VALIDATED_FORM_NAME_EDEFAULT);
        return;
      case MVCGeneratorPackage.FORM_VALIDATION__BLOCS:
        getBlocs().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.FORM_VALIDATION__VALIDATED_FORM_NAME:
        return VALIDATED_FORM_NAME_EDEFAULT == null ? validatedFormName != null : !VALIDATED_FORM_NAME_EDEFAULT.equals(validatedFormName);
      case MVCGeneratorPackage.FORM_VALIDATION__BLOCS:
        return blocs != null && !blocs.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (validatedFormName: ");
    result.append(validatedFormName);
    result.append(')');
    return result.toString();
  }

} //FormValidationImpl
